package cn.lmxdev.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        // 添加管理员登录拦截器
//        InterceptorRegistration adminRegistration = registry.addInterceptor(new AdminInterceptor());
//        adminRegistration.addPathPatterns("/page/admin/**");  // 需要拦截的
//        adminRegistration.excludePathPatterns(  // 添加不拦截路径
//                "/page/admin/login",
//                "/page/admin/register"
//        );
//
//        // 添加用户登录拦截器
//        InterceptorRegistration userRegistration = registry.addInterceptor(new UserInterceptor());
//        userRegistration.addPathPatterns("/page/user/**");  // 需要拦截的
//        userRegistration.excludePathPatterns(  // 添加不拦截路径
//                "/page/user/login",
//                "/page/user/register"
//        );
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
    }
}
